<?php
/**
 * Created by PhpStorm.
 * User: flydany
 * Date: 2018/3/21
 * Time: 22:18
 */
namespace common\models;

use Yii;

/**
 * This is the model class for table "UserBond".
 */
class UserTime extends ActiveRecord {

    /**
     * 获取employer信息
     * @return \yii\db\ActiveQuery
     */
    public function getUser()
    {
        return $this->hasOne(User::className(), ['id' => 'user_id']);
    }

    /**
     * 设置保证金过期时间
     * @return boolean
     */
    public function setBondtime($id)
    {
        $this->user_id = $id;
        $this->success_at = time();
        $this->expiry_time = strtotime("+1 year");
        return $this->save();
    }

    public function bondtimeout(){
        if($this->expiry_time <= time()){
            return true;
        }
        return false;
    }
}